﻿using System;
using System.ServiceModel.Channels;

namespace suanpan.API.Components.Channels.OAuth
{
    class OAuthBindingElement : BindingElement
    {

        public OAuthBindingElement() { }
        public OAuthBindingElement(OAuthBindingElement bindingElement){}
       
        public override BindingElement Clone()
        {
            return new OAuthBindingElement(this);
        }

        public override T GetProperty<T>(BindingContext context)
        {
            return context.GetInnerProperty<T>();
        }
        public override IChannelListener<TChannel> BuildChannelListener<TChannel>(BindingContext context)
        {

            OAuthChannelListener channelListener = new OAuthChannelListener( context);
            return (IChannelListener<TChannel>)channelListener;
        }
        public override bool CanBuildChannelListener<TChannel>(BindingContext context)
        {
            if (context == null)
                throw new ArgumentNullException("Context missing");

            if (typeof(TChannel) == typeof(IReplyChannel))
                return context.CanBuildInnerChannelListener<TChannel>();
            else
                return false;
        }
    }
}
